package com.feng.ioc.configuration;

import org.springframework.context.annotation.FilterType;
import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

public class MyTypeFilter implements TypeFilter {
    //metadataReader 读到当前正在扫描类的信息
    //metadataReaderFactory 可以获得其他任何类的信息
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //获取当前类的注解信息
        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        //获取当前类的信息
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        //获取类的路径信息
        Resource resource = metadataReader.getResource();
        System.out.println("===========>"+classMetadata.getClassName());
     if (classMetadata.getClassName().contains("Book")){
         return true;
     }
        return false;
    }
}
